using System;
using System.Collections.Generic;
using System.Text;

namespace Tortuga.Core.TortoiseCommands {
	/// <summary>
	/// "Updates the working copy in /path to HEAD. If the option /rev is given then a dialog is shown to ask the user to which revision the update should go."
	/// http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/apc.html
	/// </summary>
	public class UpdateCommand : SinglePathTortoiseCommand {
		private Revision _rev = new Revision(null);
		public UpdateCommand() : this("") { }
		public UpdateCommand(string path) : this(path, Revision.Head) { }
		public UpdateCommand(string path, Revision rev)
			: base("update", path) {
			this.Rev = rev;
			this.OptionsToBuild = new List<BuildOptionDelegate>(new BuildOptionDelegate[] {
				this.BuildPathOption,
				this.BuildRevOption,
				this.BuildNoTempFile,
				this.BuildCloseOnEnd
			});
		}

		#region	Build Rev
		/// <summary>
		/// Builds a rev option
		/// </summary>
		/// <param name="rev">The revision value.</param>
		/// <returns>/rev:7 (where this.Rev.Value = 7)</returns>
		public virtual string BuildRevOption() {
			return BuildRevOption(_rev);
		}

		/// <summary>
		/// Gets or sets the revision to which the update should go.
		/// </summary>
		public virtual Revision Rev {
			get { return _rev; }
			set { _rev = value; }
		}

		#endregion
	}
}
